<template>
  <transition name="slide">
    <music-list :songs="songs"
                :bg-image="bgImage"
                :title="title"
    ></music-list>

  </transition>

</template>

<script>
import { getSingerDetail } from 'api/singer'
import { processSongs } from 'api/song'
import MusicList from 'components/music-list/music-list'

import storage from 'good-storage'
export default {
name: "singer-detail",
  data () {
    return {
      songs: [],
      singer:{}
    }
  },
  computed: {
    bgImage () {
      return this.singer.pic
    },
    title(){
      return this.singer.name
    }
  },
  activated (){
    this._getDetail()
  },
  methods: {
    _getDetail () {
      const cached = storage.session.get('__singer__')
      this.singer = cached
        getSingerDetail(cached).then((result) =>{
          this.songs = result.songs

          //设置歌曲播放地址
          processSongs(this.songs)

    })

    }
  },
  components: {
    MusicList
  }
}
</script>

<style scoped lang="stylus" rel="stylesheet/stylus">
.slide-enter-active, .slide-leave-active
  transition: all 0.3s

.slide-enter, .slide-leave-to
  transform: translate3d(100%, 0, 0)
</style>
